package com.scqzy.shengchunqiang.sword2offer.day10;

/**
 * @Description: 剑指 Offer 46. 把数字翻译成字符串
 * @Author 盛春强
 * @Date 2021/8/19 17:39
 */
public class TranslateNum {
    public int translateNum(int num) {
        String s = String.valueOf(num);
        int[] dp = new int[s.length()+1];
        dp[0] = 1;
        dp[1] = 1;
        for (int i = 2; i <= s.length(); i++) {
            String substring = s.substring(i - 2, i);
            Integer integer = Integer.valueOf(substring);
            if (integer>=10&&integer<=25) {
                dp[i] = dp[i-1]+dp[i-2];
            } else {
                dp[i] = dp[i-1];
            }
        }
        return dp[s.length()];
    }
}
